home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / util / batch / ClickNumber.lha / ClickNumber next >
AmigaDOS Script File  |  1995-06-10  |  3KB  |  83 lines

  1. .key DEFnum,MAXnum,MINnum
  2. .bra [
  3. .ket ]
  4.  
  5. ;ClickNumber, a (cute?) hack AmiDos script to enter numbers with the mouse
  6. ;By Seumas McNally, Dark Unicorn Productions  (longbow@mcd.on.ca)
  7. ;May be used freely as long as credit is given, if it's even worth using <g>
  8.  
  9. ;Defaults, numbers out of the range of +- two hundred ten million
  10. ;(210,000,000) screw things up when they get multiplied by ten (explained
  11. ;later) and become more than +- two billion (out of signed long range)
  12. ;You could add some extra pre-multiplication checks and allow for a max of
  13. ;two billion, if you really needed numbers that high and didn't mind an
  14. ;even slower routine...
  15. .def defnum 0
  16. .def maxnum 210000000
  17. .def minnum -210000000
  18.  
  19. ;No repeated diskloading for the common commands
  20. resident c:requestchoice
  21. resident c:eval
  22.  
  23. ;This sets them to "0" if they are not numbers
  24. set cntot `eval [defnum] + 0`
  25. set cnmax `eval [maxnum] + 0`
  26. set cnmin `eval [minnum] + 0`
  27. ;Sets first message
  28. set cnmsg "( starting )"
  29.  
  30. ;Main loop
  31. lab start
  32. ;The requestor, gadgets return 1 on far left going right, far right returns 0 
  33. set cnsel `requestchoice "enter a number:  default [defnum],  max [maxnum],  min [minnum]" "$cnmsg   number: { $cntot }" "0|1|2|3|4|5|6|7|8|9|+-|<-|clr|ok"`
  34. set cnmsg "(    ..    )"
  35. ;If 0=OK was NOT selected, continue, else quit
  36. if not $cnsel eq "0"
  37.  ;If a number was selected (cnsel <=10, 0 returns 1, 1 returns 2...9 returns 10)
  38.  if not val $cnsel GT "10"
  39.   ;Ads or subs (depends on total's sign) cnadd to cntot to add digit to end
  40.   ;tot is *10 to give room for new digit, sel is -1 to get value of gadget
  41.   if val $cntot GE "0"
  42.    set cntot `eval ($cntot*10) + ($cnsel-1)`
  43.    skip minmax
  44.    ; ^For speed, whatever it may actually gain
  45.   else
  46.    set cntot `eval ($cntot*10) - ($cnsel-1)`
  47.    skip minmax
  48.   endif
  49.  else
  50.   if val $cnsel eq "11"
  51.    ;Switches around the sign of the total and sets msg
  52.    set cntot `eval $cntot - ($cntot * 2)`
  53.    set cnmsg "( negated  )"
  54.   else
  55.    if val $cnsel eq "12"
  56.     ;Divides the total by 10, these work on INTs so it chops last digit
  57.     set cntot `eval $cntot / 10`
  58.     set cnmsg "(   back   )"
  59.    else
  60.     if val $cnsel eq "13"
  61.      ;Clears total to 0
  62.      set cntot "0"
  63.      set cnmsg "( cleared  )"
  64.     endif
  65.    endif
  66.   endif
  67.  endif
  68.  lab minmax
  69.  if val $cntot GT $cnmax
  70.   ;If new total is > max, set to max
  71.   set cntot $cnmax
  72.   set cnmsg "( MAX hit  )"
  73.  endif
  74.  if val $cnmin GT $cntot
  75.   ;If new total < min, set to min
  76.   set cntot $cnmin
  77.   set cnmsg "( MIN hit  )"
  78.  endif
  79.  skip start back
  80. endif
  81. ;Return value and end
  82. echo $cntot
  83.